package com.dal.guava.controller;

import com.dal.guava.annotations.Limit;
import com.dal.guava.common.Result;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @program: spring-boot
 * @description: 限流测试类
 * @author: jian
 * @create: 2022-06-05 21:52
 **/
@RestController
@RequestMapping("api")
public class TestController {


    @GetMapping("/test2")
    @Limit(key = "testLimit2", permitsPerSecond = 1,timeunit = TimeUnit.MINUTES,message = "test2 当前排队人数较多，请稍后再试！")
    public Result test2() {
        System.out.println("令牌桶test2获取令牌成功");
        return Result.ok("获取成功");
    }

}
